package com.neusoft.elmboot.mapper;

import com.neusoft.elmboot.po.Business;
import com.neusoft.elmboot.po.Star;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StarMapper {

    @Insert("insert into star(userId, businessId) values(#{userId}, #{businessId})")
    int insertStar(Star star);

    @Delete("delete from star where userId=#{userId} and businessId=#{businessId}")
    int deleteStar(Star star);

    @Select("SELECT b.* FROM business b INNER JOIN star s ON b.businessId = s.businessId WHERE s.userId = #{userId}")
    List<Business> findStarsByUserId(String userId);

}